package Servlet;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * Servlet implementation class loginCheck
 */
public class loginCheck extends HttpServlet {
    
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String name=request.getParameter("name");
		String passwd=request.getParameter("password");
		if(name.equals("cjy")&&passwd.equals("123456")){
			response.sendRedirect("./pages/moritor.jsp");
		}
		else{
			//HttpSession session = request.getSession(); 
			request.setAttribute("passwderr", "error");
			RequestDispatcher dispatcher = request.getRequestDispatcher("/index.jsp");
			dispatcher .forward(request, response);
			//response.sendRedirect("./index.jsp");
			
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request,response);
	}

}
